from rest_framework import serializers
from cart.models import JzGoods,AddressModel,UserAddressModel,CouponModel

class JzGoodsSerializer(serializers.ModelSerializer):
    class Meta:
        model = JzGoods
        fields = "__all__"


class AddressSerializer(serializers.ModelSerializer):
    class Meta:
        model = AddressModel
        fields = ['id', 'name', 'level', 'pid']

class UserAddressSerializer(serializers.ModelSerializer):
    province = AddressSerializer()
    city = AddressSerializer()
    district = AddressSerializer()

    class Meta:
        model = UserAddressModel
        fields = ['id', 'receiver', 'phone', 'street', 'is_default', 'province', 'city', 'district']

class CouponSerializer(serializers.ModelSerializer):
    class Meta:
        model = CouponModel
        fields = ['id', 'name', 'discount_amount', 'status', 'start_time', 'end_time', 'min_spend']
